<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<head>
  <meta charset="UTF-8">
  <title>axiosVue</title>
</head>
<body>
<div id="app">
  <input type="button" value="获取笑话" @click="getjoke">
  <h2>{{joke}}</h2>
</div>
<script>
  var app = new Vue({
    el: "#app",
    data: {
      joke: "请点击按钮获取笑话，哈哈哈哈哈"
    },
    methods: {
      getjoke: function () {
        var that = this;
        axios.get("https://autumnfish.cn/api/joke").then(function (response) {
          // console.log(response);
          // console.log(response.data);
          that.joke = response.data;
        }, function (err) {

        })
      }
    }
  })
</script>
</body>
</html>
